package com.gpipe.dirwatcher;

import com.gpipe.tools.GpipeInit;

import java.util.Map;
import java.util.HashMap;


public class DirectorySnapshot {

    public static Map files = new HashMap();
    public static Map brokenPointComFiles = new HashMap();//断点文件列表和当前文件列表对比结果
    public static String lastFileName = new String();
    public static String nowFileDate = new String();
	public static String firstFileName = new String();//just for Fill data

    public static void updateNowDateByFN(){
        try{
            nowFileDate = DirectorySnapshot.lastFileName.substring(
                    DirectorySnapshot.lastFileName.indexOf("interface_")
                            + "interface_".length(),
                    DirectorySnapshot.lastFileName.indexOf("interface_")
                            + "interface_".length()+8);

        }catch (StringIndexOutOfBoundsException e){
            GpipeInit.writeLogs("--error--:待处理的文件列表中获取的最新文件名，存在问题。");
            e.printStackTrace();
        }

    }
    public static String getNowFileDate() {
        return nowFileDate;
    }

	public static void addFile(String fileName){
        files.put(fileName, fileName);
    }

    public static void removeFile(String fileName){
        files.remove(fileName);
    }

    public static boolean containsFile(String fileName){
        return files.containsKey(fileName);
    }
}
